<?php
class lib_game_list extends lib_base{
	public $table_name = "qc_game_list";
    public $pk = "id";

    public function getList($cond)
    {
        $result = $this->findAll(array($cond),'sort desc,id desc');
        if($result){
            foreach ($result as $key => $val) {
                if($val['logo']){
                    $val['logo'] = D('upload_file')->get_image_url($val['logo']);
                }
                if($val['photo']){
                    $photos_arr = explode(',', $val['photo']);
                    foreach($photos_arr as $v){
                        $val['photos'][] = D('upload_file')->get_image_url($v);
                        // $val['thumbs'][] = $v2."_thumb.jpg";
                    }
                }

                $list[] = $val;
            }
        }
        $list = formatChildData($list);
        return $list;
    }

    public function get_game_info($game_id)
    {
        $result = $this->get_info($game_id);
        if($result){
            $val = $result;
            if($val['logo']){
                $val['logo'] = D('upload_file')->get_image_url($val['logo']);
            }
            if($val['photo']){
                $photos_arr = explode(',', $val['photo']);
                foreach($photos_arr as $v){
                    $v2 = D('upload_file')->get_image_url($v);
                    $val['photos'][] = $v2;
                    $val['thumbs'][] = $v2."_thumb.jpg";
                }
            }

            $info = $val;
        }
        // $list = formatChildData($list);
        return $info;
    }

    public function get_citys($pid){
        $result = $this->findAll(array("status=1 and parent_id={$pid}"),'sort asc');
		if($result){
            foreach($result as $val){
                $res[] = $val['name'];
            }
            return $res;
        }
        return false;
		
    }

    public function site_act($doids,$status)
    {
        $arrBase = array(
            'status'=>1,
            'is_site'=>$status
        );

        return $this->update(array("{$this->pk} IN ({$doids})"),$arrBase);
    }
}